package com.boang.entity;

import java.util.Objects;
import java.util.Scanner;

/*
  @author: 13813
  @date: 2024/11/19 9:25
*/
public class ATM {
    public Bank bank;
    public Scanner scanner;

    public ATM() {
        scanner = new Scanner(System.in);
        bank = new Bank();
    }

    public void service() {
        System.out.println("请输入卡号");

        String cartNo = scanner.nextLine();
        System.out.println("请输入密码");
        String pass = scanner.nextLine();

        Account account = bank.verify(cartNo, pass);
        if (!Objects.isNull(account)) {
            do {
                System.out.println("1.存钱2.取钱3.查看");
                String cq = scanner.nextLine();
                switch (cq) {
                    case "1":
                        System.out.println("请输入要存钱的钱数");
                        int money = Integer.parseInt(scanner.nextLine());
                        bank.saveMoney(money, account);
                        break;
                    case "2":
                        System.out.println("请输入要取的钱数");
                        int my = Integer.parseInt(scanner.nextLine());
                        bank.depositMoney(my, account);
                        break;
                    case "3":
                        System.out.println(account.balance);
                        break;

                }
            } while (true);
        }
    }
}
